<template>
	<view>
		<zmm-watermark :watermark="userStore.watermark" v-if="userStore.watermark"></zmm-watermark>
		<view class="content detail">
			<!--资金明细-->
			<view class="detail-item">
				<uni-section title="资金明细" type="line"></uni-section>
				<view class="detail-content">
					<!-- <view class="detail-text">ID：<text>{{info.id}}</text></view> -->
					<view class="detail-text">
						订单编号：
						<text>{{info.orderNumber}}</text>
						<text class="detail-text-copy" @click="copyText(info.orderNumber)">复制</text>
					</view>
					<view class="detail-text">
						交易金额：<text class="money" :class="info.money < 0 ? 'money1' : 'money2'">{{info.money}}</text>
					</view>
					<view class="detail-text">
						类型：
						<uni-tag size="small" :text="arrText(capitalDetailTypeList, info.type)" />
					</view>
					<view class="detail-text">支付时间：<text>{{info.createTime}}</text></view>
					<view class="detail-text">
						支付平台：
						<uni-tag size="small" text="线下交易" v-if="info.platform === -1" />
						<uni-tag size="small" v-else :text="arrText(tradingPlatformList, info.platform)" />
					</view>
					<view class="detail-text">备注：<text>{{info.remark}}</text></view>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { computed, onMounted, ref } from 'vue';
import { tab, auth, modal } from "@/plugins"
import { getTitle } from "@/utils/getter"
import { checkPermi, checkRole, checkOnlyPermi, checkOnlyRole } from "@/utils/permission"
import { tradingPlatform } from "@/api/system/dict/data"
import { capitalDetailDetail } from "@/api/erp_api/order"
import { copyText, arrText } from '@/utils/ty.js';
import { capitalDetailTypeList } from '@/utils/config.js'
import useUserStore from '@/store/modules/user'

	const userStore = useUserStore()	
	onLoad(async (option) => {
		if (option.id) {
			await getTradingPlatform()
			id.value = option.id
			getDetail()
		}
	})
	
	// 获取支付平台
	const tradingPlatformList = ref([])
	const getTradingPlatform = () => {
		return tradingPlatform().then(res => {
			tradingPlatformList.value = res.data.map(item => {
				return {
					...item,
					value: item.dictValue,
					text: item.dictLabel
				}
			}) || []
		})
	}
	
	// 数据查询
	const id = ref('')
	const info = ref({})
	const userInfo = ref({})
	const isLoading = ref(false)
	
	const getDetail = () => {
		const params = {
			id: id.value
		}
		isLoading.value = true
		uni.showLoading({
			title: '数据加载中...'
		})
		capitalDetailDetail(params).then(res => {
			info.value = res.data || {}
			isLoading.value = false
			uni.hideLoading()
	  }).catch(() => {
			isLoading.value = false
			uni.hideLoading()
		})
	}
	
</script>

<style scoped>
</style>
